<template>
  <div class="contain">
    <div v-for="(item, index) in list" :key="index" class="box">
      <img :src="item.imgSrc" alt="" />
      <span @click="add(index)">{{ item.text }}</span>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      required: true,
    },
  },
  data() {
    return {};
  },
  methods: {
    add(index) {
      this.$emit("addFn", index);
    },
  },
};
</script>

<style scoped>
.contain {
  display: flex;
  flex-wrap: wrap;
  width: 1000px;
}

.box {
  width: 300px;
  height: 320px;
  border: 2px solid black;
  text-align: center;
}

img {
  width: 300px;
  margin-bottom: 10px;
}
</style>
